﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace OverlakeApp.Views
{
    /// <summary>
    /// The page that contains controls to change the app's settings.
    /// </summary>
    public partial class SettingsPage : PhoneApplicationPage
    {
        private Popup loadingPopup;
        private ViewModels.OverlakeViewModel vm;

        /// <summary>
        /// Initialize the SettingsPage
        /// </summary>
        public SettingsPage()
        {
            InitializeComponent();

            loadingPopup = new Popup()
                {
                    Child = new LoginLoadingPopup()
                };

            this.vm = this.DataContext as ViewModels.OverlakeViewModel;
            this.vm.LoginCompleted += new EventHandler<AppService.LoginCompletedEventArgs>(vm_LoginCompleted);
        }

        void vm_LoginCompleted(object sender, AppService.LoginCompletedEventArgs e)
        {
            loadingPopup.IsOpen = false;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            loadingPopup.IsOpen = true;
        }
    }
}